<?php require_once 'source.php';?>
<?php require_once 'config.php';?>
<?php require_once 'dao/dao_db.php';?>
<?php require_once 'dao/dao_qa.php';?>
<?php require_once 'dao/dao_sys_manage.php';?>
<?php 
	$result=is_bbs_on();
	$row=mysql_fetch_array($result);
	if($row['BBSSWITCH']==OFF){
		mysql_close();
		header('Location: error.php?errcode=2');
		exit;
	}
?>
<?php
session_start();
session_cache_limiter('private');
$id=$_GET['qid'];
$result=get_question_detail($id);
if(mysql_num_rows($result)!=0){
	$row=mysql_fetch_array($result);
	if($row['TYPE']==GROUPQUESTIONCODE){
		$groupresult1=mysql_fetch_array(get_group($_SESSION['userid']));
		$groupresult2=mysql_fetch_array(get_group($row['QAUTHOR']));
		if($groupresult1['USERGROUP']!=$groupresult2['USERGROUP']){
			header("LOCATION:error.php?errcode=2");
		}
	}
}else{
	mysql_close();
	header("LOCATION:error.php?errcode=1");
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><?php echo SYSTITLE?></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="css/style.css" />
</head>
<body class="w">
<div class="wrapper wrapper_index">
	<div class="banner">
	</div>
	<div id="news_detail">
		<div style="text-align:center; padding:8px;">
			<h2><?php echo $row['TITLE']?></h2>
			<span class="newsdate"><?php echo get_username($row['QAUTHOR'])?> <?php echo $row['QTIME']?></span>
		</div>
		<hr/>
		<div class="content">
			<?php echo nl2br($row['QCONTENT'])?>
		</div>
	</div>
	<hr/>
	<div id="qcommnet">
	<?php 
		if($row['CCONTENT']!=''){
			mysql_data_seek($result,0);
			while(($row=mysql_fetch_array($result))!=false){
	?>
		<div id="cmt">
		<h5><?php echo get_username($row['CAUTHOR']).PUBLICTIME.$row['CTIME']?></h5>
		<?php echo nl2br($row['CCONTENT'])?>
		</div>
	<?php 
			}
		}
	if(isset($_SESSION['userid'])){
	?>
		<form action="service/service_save_questions_comment.php" method="post">
		<div id="comment">
			<textarea rows="5" name="comment"></textarea>
			<input type="submit" value="<?php echo SUBMIT?>"/>
			<input type="hidden" name="titleid" value="<?php echo $id?>"/>
		</div>
		</form>
	<?php 
	}
	mysql_close();
	?>
	</div>
</div>
</body>
</html>
